'''
Created on May 7, 2012
TC ID: Ecom_5034
Desc: Kiem thu chuc nang tuy chinh thong tin bai hoc
@author: lavang
'''
import unittest
import time
from HTMLTestRunner import HTMLTestRunner
from Functions.loginPageFunc import login
from Functions.globalFunc import preCondition, readData, endCondition
from Functions.lessonInformationFunc import clickOnLesson,\
    clickOnLessonInformation, clickOnEditInformation, clickOnAddDescription,\
    inputDescription, clickOnLinkLessonInformation, verifyDescriptionExist

username=readData("username",index=2)
password=readData("password",index=2)
tm_lesson=readData("lessonName",index=3)
tm_content='This is description'
class Ecom_5034(unittest.TestCase):


    def setUp(self):
        preCondition(self)

    def test_Ecom_5034(self):
        print "Buoc 1: Dang nhap website"
        login(self,username,password)
        
        print "Buoc 2: Click vao bai hoc"
        clickOnLesson(self,tm_lesson)
        
        print "Buoc 3: Click vao 'Lesson information' "
        clickOnLessonInformation(self)
        
        print "Buoc 4: Click vao 'Edit information' "
        clickOnEditInformation(self)
        
        print "Buoc 5: Click 'Add' Description "
        clickOnAddDescription(self)
        
        print "Buoc 6: Nhap Description"
        inputDescription(self,tm_content)
        
        print "Buoc 7: Click 'Lesson infomation' "
        clickOnLinkLessonInformation(self)
        
        print "Buoc 8: Xac nhan bai hoc duoc them thong tin thanh cong"
        self.assertTrue(verifyDescriptionExist(self,tm_content), "Failed!")
        print "Passed! Bai hoc duoc them thong tin thanh cong"
    
    def tearDown(self):
        endCondition(self)


if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    testSuite = unittest.TestSuite()
    suite = unittest.TestLoader().loadTestsFromTestCase(Ecom_5034)
    dateTime = time.strftime('%Y%m%d_%H_%M_%S')
    buf = file("../../Report/TestResults" + "_" + dateTime + ".html",'wb')
    runner = HTMLTestRunner(
                    stream=buf,
                    title='Test Results',
                    description='Kiem thu chuc nang tuy chinh thong tin bai hoc'
                    )
    runner.run(suite)